#ifndef __THREADPOOL_H__
#define __THREADPOOL_H__

#include "taskQueue.h"
#include <vector>
#include <thread>
#include <functional>

using std::vector;
using std::thread;
using std::function;

class Task;

class ThreadPool
{
public:
	ThreadPool(size_t threadNum,size_t capacity);
	~ThreadPool();

	void start();
	void stop();

	void addTask(function<void()> && pTask);

private:
	function<void()> getTask();
	void doTask();

private:
	size_t _threadNum;
	vector<thread> _threads;
	size_t _capacity;
	TaskQueue _taskQueue;
	bool _isExit;

};

#endif
